

let mixins={
    mounted() {},
    data() {
       return {
             initData:{
                term:'', //期限 单位年
                income:'',//总收入 单位 元
                investmentAmount:'', // 投资金额 ，定投金额，根据type 字段判断获取
                rate:'',// 年化收益率 单位%
                type:'' ,// 类型 0 一次性投入  1月定投 2 年定投
                totalInvestment:'',//总投入金额
            }
         }
    },
    methods: {
        close(){
            window.location.href = 'closeLicaiShiPage'
        },
      appgetdata(res){
          var _this=this
          if (typeof res !='object') {
            _this.initData=eval('(' + res + ')')
          }else{
            _this.initData=res
          }

           if (_this.initData.type==0) {
                this.initData.typeName='一次性投入'
            }
            if (_this.initData.type==1) {
                this.initData.typeName='每月定投'
            }
            if (_this.initData.type==2) {
                this.initData.typeName='每年定投'
            }
            setTimeout(()=>{
                _this.initpie('pieCon')
            })

       },
       initpie(id,data){
        var _this=this
         var pie = document.getElementById(id); 
         var chartsModel = echarts.init(pie)


         var option = {
            title: {
                text: '单位：元',
                textStyle:{
                    fontSize: 13,
                },
                top:20
            },
            legend: {},
            tooltip: {},
            dataset: {},
            xAxis: {
                type: 'category',
                axisTick:{       //x轴刻度线
                    show:false
                },
                data:[`${_this.initData.typeName}${_this.initData.investmentAmount}元`]
            },
            yAxis: {
                type: 'value',
                axisLine:{
                    show:false
                },
                axisTick:{       //y轴刻度线
                    show:false
                },
                axisLabel:{
                    show:false
                },
                splitLine:{
                    show:false
                },
               
            },
            // Declare several bar series, each will be mapped
            // to a column of dataset.source by default.
            series: [
                {
                    type: 'bar',
                    data:[_this.initData.totalInvestment],
                    name:"总投入",
                    itemStyle :{
                        normal: {
                            label: {
                                show: true,
                                position: 'top', //柱子上方显示 数值
                                // formatter: '{c}' //数值加上'%'
                            },
                            color:'#2EC7C9'
                        },
                        
                    },
                    markLine:{
                        label:{
                        normal:{
                        position:'right',
                        show: false,
                        }
                        },
                        data:[
                        {
                        name:'总投入',
                        yAxis:_this.initData.totalInvestment
                        },
                        ]
                        }
                },
                {
                    type: 'bar',
                    data:[_this.initData.income],
                    name:"总收入",
                    itemStyle :{
                        normal: {
                            label: {
                                show: true,
                                position: 'top', //柱子上方显示 数值
                                // formatter: '{c}' //数值加上'%'
                            },
                            color:'#5AB1EF'
                        }
                    },
                    markLine:{
                        label:{
                        normal:{
                        position:'right',
                        show: false,
                        }
                        },
                        data:[
                        {
                        name:'总收入',
                        yAxis:_this.initData.income
                        },
                        ]
                        }
                    
                },
                
            ],
            graphic: [
                {
                   type: 'group',
                   left: 'center',
                   bottom: 130,
                   children: [
                       {
                           type: 'text',
                           z: 100,
                           left: 'center',
                           top: 'middle',
                           style: {
                               fill: '#DC7700',
                               text: _this.initData.income-_this.initData.totalInvestment,
                               font: '14px Microsoft YaHei'
                           }
                       }
                   ]
               }
           ],
        };
        
        

         chartsModel.setOption(option);
         window.onresize = function () {
             chartsModel.resize();
         } 
     },
    },
}




